package zy.blue7.gui.netty.custom.qq.service.impl;

import io.netty.channel.Channel;
import zy.blue7.gui.netty.custom.qq.Server;
import zy.blue7.gui.netty.custom.qq.message.GroupMessage;
import zy.blue7.gui.netty.custom.qq.message.Message;
import zy.blue7.gui.netty.custom.qq.service.MessageHandler;

import java.io.IOException;
import java.util.List;

/**
 * @author blue7
 * @version 1.0
 * @date 2022/2/28 16:48
 */
public class GroupMessageHandlerImpl implements MessageHandler {
    @Override
    public void handle(Message message, Channel channel) throws IOException {

        System.out.println(message);
        System.out.println(message.getClass());
        System.out.println("SingleMessage....");

        GroupMessage groupMessage = (GroupMessage) message;

        List<Channel> list = Server.groupMap.get(groupMessage.getTo());
        list.forEach(channel1 -> {
            sendMessage(groupMessage, channel1);
            System.out.println("*******************************************************************");
        });


    }
}
